{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "369e4108",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 列表的基本用法\n",
    "\n",
    "## 1. 增加的方法\n",
    "1.1 增加 append() 增加在list的末尾\n",
    "names.append(1)\n",
    "print(names)\n",
    "1.2 插入 insert() 可以指定位置增加元素\n",
    "names.insert(1,'yougege') print(\"insert之后的names：\",names)\n",
    "\n",
    "2. 删除 remove 和 pop\n",
    "#优势：如果删除list中多个元素时，remove比较合适\n",
    "\n",
    "2.1 remove()一般情况下 使用remove先用in做判断\n",
    "if 10001 in names: names.remove(10001) print(\"remove删除的结果：\",names)\n",
    "\n",
    "2.2 pop() 删除位置为1的这个元素\n",
    "names.pop(-1) print(\"pop()方法后的names:\",names)\n",
    "\n",
    "3. index()索引 查看该元素如10001 在stu_id中第一个出现的位置索引\n",
    "print(stu_id.index(10001))\n",
    "\n",
    "4. clear()清除所有数据\n",
    "names.clear() print(\"清除names列表后的值：\",names)\n",
    "\n",
    "5.count()查看列表元素出现的个数，（简单应用）统计分数出现的次数\n",
    "print(\"count方法的结果:\",stu_id.count(10001)) print(names)\n",
    "\n",
    "6. extend() 是给指定的list进行扩充\n",
    "names.extend(stu_id) print(names)\n",
    "\n",
    "列表的高级方法\n",
    "copy（）的使用：\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "55131aa7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
